/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author machine
 */
@Entity
@Table(name = "idiomas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Idiomas.findAll", query = "SELECT i FROM Idiomas i"),
    @NamedQuery(name = "Idiomas.findByIdidiomas", query = "SELECT i FROM Idiomas i WHERE i.ididiomas = :ididiomas"),
    @NamedQuery(name = "Idiomas.findByIdioma", query = "SELECT i FROM Idiomas i WHERE i.idioma = :idioma")})
public class Idiomas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ididiomas")
    private Integer ididiomas;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "idioma")
    private String idioma;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ididiomas")
    private Collection<Idiomapeliculas> idiomapeliculasCollection;

    public Idiomas() {
    }

    public Idiomas(Integer ididiomas) {
        this.ididiomas = ididiomas;
    }

    public Idiomas(Integer ididiomas, String idioma) {
        this.ididiomas = ididiomas;
        this.idioma = idioma;
    }

    public Integer getIdidiomas() {
        return ididiomas;
    }

    public void setIdidiomas(Integer ididiomas) {
        this.ididiomas = ididiomas;
    }

    public String getIdioma() {
        return idioma;
    }

    public void setIdioma(String idioma) {
        this.idioma = idioma;
    }

    @XmlTransient
    public Collection<Idiomapeliculas> getIdiomapeliculasCollection() {
        return idiomapeliculasCollection;
    }

    public void setIdiomapeliculasCollection(Collection<Idiomapeliculas> idiomapeliculasCollection) {
        this.idiomapeliculasCollection = idiomapeliculasCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ididiomas != null ? ididiomas.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Idiomas)) {
            return false;
        }
        Idiomas other = (Idiomas) object;
        if ((this.ididiomas == null && other.ididiomas != null) || (this.ididiomas != null && !this.ididiomas.equals(other.ididiomas))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "beans.Idiomas[ ididiomas=" + ididiomas + " ]";
    }
    
}
